package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.WaresDao;
import dao.impl.IWaresDao;
import entity.Img;
import entity.Wares;

public class ShowServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		WaresDao wd = new IWaresDao();
		Wares w = new Wares();
		List<Img> list = new ArrayList<Img>();
		
		String wid = request.getParameter("wid");
		int id=0;
		if (wid!=""&&wid!=null) {
			id = Integer.parseInt(wid);
			w = wd.Findware(id);
			list = wd.Findwareimg(id);
			
		}
		request.getSession().setAttribute("wares", w);
		request.getSession().setAttribute("list", list);
		request.getRequestDispatcher("info.jsp").forward(request, response);
		
	}

}
